HAL MDF I/O operations migration

This section provides information about the HAL MDF function migration.

Note

  • In HAL1, a single driver handles both MDF and ADF peripherals.

  • In HAL2, the HAL MDF driver has been split into two separate drivers HAL MDF and HAL ADF. For more details, see : MDF specific concept.

  • In HAL1, there are some functions applicable for:

    • Both MDF and ADF peripheral.

    • MDF peripheral only.

    • ADF peripheral only.

  • In the following migration document when the function is applicable for both MDF and ADF the migration describes how to move from HAL1 MDF to HAL2 MDF. The same applies for ADF, example:

  • In HAL1, HAL_MDF_AcqStop function becomes:

    • HAL_MDF_DFLT_StopAcq in HAL2 MDF driver.

    • HAL_ADF_DFLT_StopAcq in HAL2 ADF driver.

  • When the function is applicable only for MDF the migration provides the equivalent for MDF.

  • When the function is applicable only for ADF the migration provides the equivalent for ADF.

Functions applicable for MDF and ADF

HAL MDF start MDF acquisition using polling

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_AcqStart function configures the digital filter and starts data acquisition in polling mode for both MDF and ADF:


HAL_MDF_AcqStart(MDF_HandleTypeDef *hmdf,
                 const MDF_FilterConfigTypeDef *pFilterConfig)

In HAL2, new API HAL_MDF_DFLT_SetConfig is provided to configure the digital filter and then start data acquisition using HAL_MDF_DFLT_StartAcq API:

HAL_MDF_DFLT_SetConfig(hal_mdf_handle_t *hmdf,
                       hal_mdf_block_index_t digital_filter_index,
                       const hal_mdf_digital_filter_config_t *p_config)
HAL_MDF_DFLT_StartAcq(hal_mdf_handle_t *hmdf,
                      hal_mdf_block_index_t digital_filter_index)

For ADF the corresponding functions are HAL_ADF_DFLT_SetConfig and HAL_ADF_DFLT_StartAcq.

Example usage

MDF_HandleTypeDef hmdf;
MDF_FilterConfigTypeDef filter_cfg;
HAL_MDF_AcqStart(&hmdf, &filter_cfg);
hal_mdf_handle_t hmdf;
hal_mdf_digital_filter_config_t filter_cfg;
HAL_MDF_DFLT_SetConfig(&hmdf, HAL_MDF_BLOCK_INDEX_0, &filter_cfg);
HAL_MDF_DFLT_StartAcq(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF start MDF acquisition using DMA

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_AcqStart_DMA function configures the digital filter and starts data acquisition in DMA mode for both MDF and ADF:


HAL_MDF_AcqStart_DMA(MDF_HandleTypeDef *hmdf,
                     const MDF_FilterConfigTypeDef *pFilterConfig,
                     const MDF_DmaConfigTypeDef *pDmaConfig)

In HAL2, new API HAL_MDF_DFLT_SetConfig is provided to configure the digital filter and then start data acquisition using HAL_MDF_DFLT_StartAcq_DMA API:

HAL_MDF_DFLT_SetConfig(hal_mdf_handle_t *hmdf,
                       hal_mdf_block_index_t digital_filter_index,
                       const hal_mdf_digital_filter_config_t *p_config)
HAL_MDF_DFLT_StartAcq_DMA(hal_mdf_handle_t *hmdf,
                          hal_mdf_block_index_t digital_filter_index,
                          const hal_mdf_dma_config_t *p_dma_config)

For ADF the corresponding functions are HAL_ADF_DFLT_SetConfig and HAL_ADF_DFLT_StartAcq_DMA.

Example usage

MDF_HandleTypeDef hmdf;
MDF_FilterConfigTypeDef filter_cfg;
MDF_DmaConfigTypeDef dma_cfg;
HAL_MDF_AcqStart_DMA(&hmdf, &filter_cfg, &dma_cfg);
hal_mdf_handle_t hmdf;
hal_mdf_digital_filter_config_t filter_cfg;
hal_mdf_dma_config_t dma_cfg;
HAL_MDF_DFLT_SetConfig(&hmdf, HAL_MDF_BLOCK_INDEX_0, &filter_cfg);
HAL_MDF_DFLT_StartAcq_DMA(&hmdf, HAL_MDF_BLOCK_INDEX_0, &dma_cfg);

HAL MDF start MDF acquisition using interrupt

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_AcqStart_IT function configures the digital filter and starts data acquisition in interruption mode for both MDF and ADF:


HAL_MDF_AcqStart_IT(MDF_HandleTypeDef *hmdf,
                    const MDF_FilterConfigTypeDef *pFilterConfig)

In HAL2, new API HAL_MDF_DFLT_SetConfig is provided to configure the digital filter and then start data acquisition using HAL_MDF_DFLT_StartAcq_IT API:

HAL_MDF_DFLT_SetConfig(hal_mdf_handle_t *hmdf,
                       hal_mdf_block_index_t digital_filter_index,
                       const hal_mdf_digital_filter_config_t *p_config)
HAL_MDF_DFLT_StartAcq_IT(hal_mdf_handle_t *hmdf,
                         hal_mdf_block_index_t digital_filter_index)

For ADF the corresponding functions are HAL_ADF_DFLT_SetConfig and HAL_ADF_DFLT_StartAcq_IT.

Example usage

MDF_HandleTypeDef hmdf;
MDF_FilterConfigTypeDef filter_cfg;
HAL_MDF_AcqStart_IT(&hmdf, &filter_cfg);
hal_mdf_handle_t hmdf;
hal_mdf_digital_filter_config_t filter_cfg;
HAL_MDF_DFLT_SetConfig(&hmdf, HAL_MDF_BLOCK_INDEX_0, &filter_cfg);
HAL_MDF_DFLT_StartAcq_IT(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF stop MDF acquisition using polling

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_AcqStop function stops data acquisition in polling mode for both MDF and ADF:

HAL_MDF_AcqStop(MDF_HandleTypeDef *hmdf)

In HAL2, use HAL_MDF_DFLT_StopAcq function to stop data acquisition:

HAL_MDF_DFLT_StopAcq(hal_mdf_handle_t *hmdf,
                     hal_mdf_block_index_t digital_filter_index)

For ADF the corresponding function is HAL_ADF_DFLT_StopAcq.

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_AcqStop(&hmdf);
hal_mdf_handle_t hmdf;
HAL_MDF_DFLT_StopAcq(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF stop acquisition using DMA

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_AcqStop_DMA function stops data acquisition in DMA mode for both MDF and ADF:

HAL_MDF_AcqStop_DMA(MDF_HandleTypeDef *hmdf)

In HAL2, use HAL_MDF_DFLT_StopAcq_DMA function to stop data acquisition:

HAL_MDF_DFLT_StopAcq_DMA(hal_mdf_handle_t *hmdf,
                         hal_mdf_block_index_t digital_filter_index)

For ADF the corresponding function is HAL_ADF_DFLT_StopAcq_DMA.

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_AcqStop_DMA(&hmdf);
hal_mdf_handle_t hmdf;
HAL_MDF_DFLT_StopAcq_DMA(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF stop acquisition using interrupt

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_AcqStop_IT function stops data acquisition in interruption mode for both MDF and ADF:

HAL_MDF_AcqStop_IT(MDF_HandleTypeDef *hmdf)

In HAL2, use HAL_MDF_DFLT_StopAcq_IT function to stop data acquisition:

HAL_MDF_DFLT_StopAcq_IT(hal_mdf_handle_t *hmdf,
                        hal_mdf_block_index_t digital_filter_index)

For ADF the corresponding function is HAL_ADF_DFLT_StopAcq_IT.

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_AcqStop_IT(&hmdf);
hal_mdf_handle_t hmdf;
HAL_MDF_DFLT_StopAcq_IT(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF start clock absence detection using interrupt

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_CkabStart_IT function starts clock absence detection in interruption mode for both MDF and ADF:

HAL_MDF_CkabStart_IT(MDF_HandleTypeDef *hmdf)

In HAL2, use HAL_MDF_SITF_StartClockAbsenceDetect_IT function to start clock absence detection:

HAL_MDF_SITF_StartClockAbsenceDetect_IT(const hal_mdf_handle_t *hmdf,
                                        hal_mdf_block_index_t serial_interface_index)

For ADF the corresponding function is HAL_ADF_SITF_StartClockAbsenceDetect_IT.

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_CkabStart_IT(&hmdf);
hal_mdf_handle_t hmdf;
HAL_ADF_SITF_StartClockAbsenceDetect_IT(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF stop clock absence detection using interrupt

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_CkabStop_IT function stops clock absence detection in interruption mode for both MDF and ADF:

HAL_MDF_CkabStop_IT(MDF_HandleTypeDef *hmdf)

In HAL2, use HAL_MDF_SITF_StopClockAbsenceDetect_IT function to stop clock absence detection:

HAL_MDF_SITF_StopClockAbsenceDetect_IT(const hal_mdf_handle_t *hmdf,
                                       hal_mdf_block_index_t serial_interface_index)

For ADF the corresponding function is HAL_ADF_SITF_StopClockAbsenceDetect_IT.

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_CkabStop_IT(&hmdf);
hal_mdf_handle_t hmdf;
HAL_MDF_SITF_StopClockAbsenceDetect_IT(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF generate trigger output

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_GenerateTrgo function generates trigger output for both MDF and ADF:

HAL_MDF_GenerateTrgo(const MDF_HandleTypeDef *hmdf)

In HAL2, use HAL_MDF_EnableTriggerOutput function to generate trigger output:

HAL_MDF_EnableTriggerOutput(const hal_mdf_handle_t *hmdf)

For ADF the corresponding function is HAL_ADF_EnableTriggerOutput.

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_GenerateTrgo(&hmdf);
hal_mdf_handle_t hmdf;
HAL_MDF_EnableTriggerOutput(&hmdf);

HAL MDF get acquisition value

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_GetAcqValue function gets acquisition value for both MDF and ADF:

HAL_MDF_GetAcqValue(const MDF_HandleTypeDef *hmdf, int32_t *pValue)

In HAL2, use HAL_MDF_DFLT_GetAcqValue function to get acquisition value:

HAL_MDF_DFLT_GetAcqValue(const hal_mdf_handle_t *hmdf,
                         hal_mdf_block_index_t digital_filter_index)

For ADF the corresponding function is HAL_ADF_DFLT_GetAcqValue.

Example usage

MDF_HandleTypeDef hmdf;
int32_t acq_value;
HAL_MDF_GetAcqValue(&hmdf, &acq_value);
hal_mdf_handle_t hmdf;
int32_t acq_value;
acq_value = HAL_MDF_DFLT_GetAcqValue(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF get delay value

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_GetDelay function gets delay value for both MDF and ADF:

HAL_MDF_GetDelay(const MDF_HandleTypeDef *hmdf, uint32_t *pDelay)

In HAL2, use HAL_MDF_DFLT_GetSamplesDelay function to get delay value:

HAL_MDF_DFLT_GetSamplesDelay(const hal_mdf_handle_t *hmdf,
                             hal_mdf_block_index_t digital_filter_index)

For ADF the corresponding function is HAL_ADF_DFLT_GetSamplesDelay.

Example usage

MDF_HandleTypeDef hmdf;
uint32_t delay;
HAL_MDF_GetDelay(&hmdf, &delay);
hal_mdf_handle_t hmdf;
uint32_t delay;
delay = HAL_MDF_DFLT_GetSamplesDelay(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF set delay value

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_SetDelay function sets samples delay for both MDF and ADF:

HAL_MDF_SetDelay(MDF_HandleTypeDef *hmdf, uint32_t Delay)

In HAL2, use HAL_MDF_DFLT_SetSamplesDelay function to set samples delay:

HAL_MDF_DFLT_SetSamplesDelay(const hal_mdf_handle_t *hmdf,
                             hal_mdf_block_index_t digital_filter_index,
                             uint32_t samples_delay)

For ADF the corresponding function is HAL_ADF_DFLT_SetSamplesDelay.

Example usage

MDF_HandleTypeDef hmdf;
int32_t delay = 50;
HAL_MDF_SetDelay(&hmdf,delay);
hal_mdf_handle_t hmdf;
int32_t delay = 50;
HAL_MDF_DFLT_SetSamplesDelay(&hmdf, HAL_MDF_BLOCK_INDEX_0, delay);

HAL MDF get gain value

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_GetGain function gets current gain for both MDF and ADF:

HAL_MDF_GetGain(const MDF_HandleTypeDef *hmdf, int32_t *pGain)

In HAL2, use HAL_MDF_DFLT_GetGain function to get current gain:

HAL_MDF_DFLT_GetGain(const hal_mdf_handle_t *hmdf,
                     hal_mdf_block_index_t digital_filter_index)

For ADF the corresponding function is HAL_ADF_DFLT_GetGain.

Example usage

MDF_HandleTypeDef hmdf;
uint32_t gain;
HAL_MDF_GetGain(&hmdf, &gain);
hal_mdf_handle_t hmdf;
uint32_t gain;
gain = HAL_MDF_DFLT_GetGain(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF set gain value

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_SetGain function sets gain value for both MDF and ADF:

HAL_MDF_SetGain(MDF_HandleTypeDef *hmdf, int32_t Gain)

In HAL2, use HAL_MDF_DFLT_SetGain function to set gain value:

HAL_MDF_DFLT_SetGain(const hal_mdf_handle_t *hmdf,
                     hal_mdf_block_index_t digital_filter_index,
                     int32_t gain)

For ADF the corresponding function is HAL_ADF_DFLT_SetGain.

Example usage

MDF_HandleTypeDef hmdf;
int32_t gain = 10;
HAL_MDF_SetGain(&hmdf,gain);
hal_mdf_handle_t hmdf;
int32_t gain = 10;
HAL_MDF_DFLT_SetGain(&hmdf, HAL_MDF_BLOCK_INDEX_0, gain);

HAL MDF poll for acquisition completion

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_PollForAcq function waits available acquisition in polling mode for both MDF and ADF:

HAL_MDF_PollForAcq(MDF_HandleTypeDef *hmdf, uint32_t Timeout)

In HAL2, use HAL_MDF_DFLT_PollForAcq function to wait available acquisition in polling mode:

HAL_MDF_DFLT_PollForAcq(hal_mdf_handle_t *hmdf,
                        hal_mdf_block_index_t digital_filter_index,
                        uint32_t timeout_ms)

For ADF the corresponding function is HAL_ADF_DFLT_PollForAcq.

Example usage

MDF_HandleTypeDef hmdf;
uint32_t timeout = 1000;
HAL_MDF_PollForAcq(&hmdf,timeout);
hal_mdf_handle_t hmdf;
uint32_t timeout = 1000;
HAL_MDF_DFLT_PollForAcq(&hmdf, HAL_MDF_BLOCK_INDEX_0, timeout);

HAL MDF poll for clock absence detection

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_PollForCkab function detects clock absence in polling mode for both MDF and ADF:

HAL_MDF_PollForCkab(MDF_HandleTypeDef *hmdf, uint32_t Timeout)

In HAL2, if the user wants to wait until clock absence is detected, then he need to call HAL_MDF_SITF_IsClockAbsenceDetected function in a loop with a dedicated timeout in the applicative side:

HAL_MDF_SITF_IsClockAbsenceDetected(const hal_mdf_handle_t *hmdf,
                                    hal_mdf_block_index_t serial_interface_index)

For ADF the corresponding function is HAL_ADF_SITF_IsClockAbsenceDetected.

Example usage

MDF_HandleTypeDef hmdf;
uint32_t timeout = 1000;
HAL_MDF_PollForCkab(&hmdf, timeout);
hal_mdf_handle_t hmdf;
HAL_MDF_SITF_IsClockAbsenceDetected(&hmdf, HAL_MDF_BLOCK_INDEX_0);

Functions applicable for MDF only

HAL MDF get offset value

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_GetOffset function gets current offset compensation for MDF only (not used with ADF):

HAL_MDF_GetOffset(const MDF_HandleTypeDef *hmdf, int32_t *pOffset)

In HAL2, use HAL_MDF_DFLT_GetOffsetCompensation function to get current offset compensation:

HAL_MDF_DFLT_GetOffsetCompensation(const hal_mdf_handle_t *hmdf,
                                   hal_mdf_block_index_t digital_filter_index)

Example usage

MDF_HandleTypeDef hmdf;
int32_t offset;
HAL_MDF_GetOffset(&hmdf, &offset);
hal_mdf_handle_t hmdf;
int32_t offset;
offset = HAL_MDF_DFLT_GetOffsetCompensation(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF set offset value

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_SetOffset function sets offset value for MDF only (not used with ADF):

HAL_MDF_SetOffset(MDF_HandleTypeDef *hmdf, int32_t Offset)

In HAL2, use HAL_MDF_DFLT_SetOffsetCompensation function to set offset value:

HAL_MDF_DFLT_SetOffsetCompensation(const hal_mdf_handle_t *hmdf,
                                    hal_mdf_block_index_t digital_filter_index,
                                    int32_t offset_compensation)

Example usage

MDF_HandleTypeDef hmdf;
int32_t offset = 100;
HAL_MDF_SetOffset(&hmdf,offset);
hal_mdf_handle_t hmdf;
int32_t offset = 100;
HAL_MDF_DFLT_SetOffsetCompensation(&hmdf, HAL_MDF_BLOCK_INDEX_0, offset);

HAL MDF get snapshot acquisition value

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_GetSnapshotAcqValue function gets snapshot acquisition value for MDF only (not used with ADF):

HAL_MDF_GetSnapshotAcqValue(MDF_HandleTypeDef *hmdf,
                            MDF_SnapshotParamTypeDef *pSnapshotParam)

In HAL2, use HAL_MDF_DFLT_GetSnapshotAcqValue function to get snapshot acquisition value:

HAL_MDF_DFLT_GetSnapshotAcqValue(const hal_mdf_handle_t *hmdf,
                                 hal_mdf_block_index_t digital_filter_index,
                                 hal_mdf_dflt_snapshot_param_t *p_snapshot_param)

Example usage

MDF_HandleTypeDef hmdf;
MDF_SnapshotParamTypeDef snapshot;
HAL_MDF_GetSnapshotAcqValue(hmdf, &snapshot);
hal_mdf_handle_t hmdf;
hal_mdf_dflt_snapshot_param_t snapshot;
HAL_MDF_DFLT_GetSnapshotAcqValue(hmdf, HAL_MDF_BLOCK_INDEX_0, &snapshot);

HAL MDF start old data acquisition using polling

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_OldStart function configures and enables out of limit detector in polling mode for MDF only (not used with ADF):

HAL_MDF_OldStart(MDF_HandleTypeDef *hmdf,
                 const MDF_OldConfigTypeDef *pOldConfig)

In HAL2, new API HAL_MDF_OLD_SetConfig is provided to configure the out of limit detector and then start detection using HAL_MDF_OLD_Start API:

HAL_MDF_OLD_SetConfig(hal_mdf_handle_t *hmdf,
                      hal_mdf_block_index_t out_of_limit_detector_index,
                      const hal_mdf_old_config_t *p_config)
HAL_MDF_OLD_Start(hal_mdf_handle_t *hmdf,
                  hal_mdf_block_index_t out_of_limit_detector_index)

Example usage

MDF_HandleTypeDef hmdf;
MDF_OldConfigTypeDef old_cfg;
HAL_MDF_OldStart(&hmdf, &old_cfg);
hal_mdf_handle_t hmdf;
hal_mdf_old_config_t old_cfg;
HAL_MDF_OLD_SetConfig(&hmdf, HAL_MDF_BLOCK_INDEX_0, &old_cfg);
HAL_MDF_OLD_Start(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF start old data acquisition using interrupt

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_OldStart_IT function configures and enables out of limit detector in interrupt mode for MDF only (not used with ADF):

HAL_MDF_OldStart_IT(MDF_HandleTypeDef *hmdf,
                    const MDF_OldConfigTypeDef *pOldConfig)

In HAL2, new API HAL_MDF_OLD_SetConfig is provided to configure the out of limit detector and then start detection using HAL_MDF_OLD_Start_IT API:

HAL_MDF_OLD_SetConfig(hal_mdf_handle_t *hmdf,
                      hal_mdf_block_index_t out_of_limit_detector_index,
                      const hal_mdf_old_config_t *p_config)
HAL_MDF_OLD_Start_IT(hal_mdf_handle_t *hmdf,
                     hal_mdf_block_index_t out_of_limit_detector_index)

Example usage

MDF_HandleTypeDef hmdf;
MDF_OldConfigTypeDef old_cfg;
HAL_MDF_OldStart_IT(&hmdf, &old_cfg);
hal_mdf_handle_t hmdf;
hal_mdf_old_config_t old_cfg;
HAL_MDF_OLD_SetConfig(&hmdf, HAL_MDF_BLOCK_INDEX_0, &old_cfg);
HAL_MDF_OLD_Start_IT(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF stop old data acquisition using polling

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_OldStop function stops out of limit detector in polling mode for MDF only (not used with ADF):

HAL_MDF_OldStop(MDF_HandleTypeDef *hmdf);

In HAL2, use HAL_MDF_OLD_Stop function to stop out of limit detector in polling mode:

HAL_MDF_OLD_Stop(hal_mdf_handle_t *hmdf,
                 hal_mdf_block_index_t out_of_limit_detector_index)

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_OldStop(&hmdf);
hal_mdf_handle_t hmdf;
HAL_MDF_OLD_Stop(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF stop old data acquisition using interrupt

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_OldStop_IT function stops out of limit detector in interruption mode for MDF only (not used with ADF):

HAL_MDF_OldStop_IT(MDF_HandleTypeDef *hmdf)

In HAL2, use HAL_MDF_OLD_Stop_IT function to stop out of limit detector in interruption mode:

HAL_MDF_OLD_Stop_IT(hal_mdf_handle_t *hmdf,
                    hal_mdf_block_index_t out_of_limit_detector_index)

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_OldStop_IT(&hmdf);
hal_mdf_handle_t hmdf;
HAL_MDF_OLD_Stop_IT(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF Poll for OLD event

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_PollForOld function polls for OLD event in polling mode for MDF only (not used with ADF):

HAL_MDF_PollForOld(MDF_HandleTypeDef *hmdf,
                   uint32_t Timeout,
                   uint32_t *pThresholdInfo)

In HAL2, if the user wants to wait until old event is detected, then he need to call HAL_MDF_OLD_IsDetected function in a loop with a dedicated timeout in the applicative side:

HAL_MDF_OLD_IsDetected(const hal_mdf_handle_t *hmdf,
                       hal_mdf_block_index_t out_of_limit_detector_index,
                       hal_mdf_old_threshold_info_t *p_threshold_info)

Example usage

MDF_HandleTypeDef hmdf;
uint32_t timeout = 1000;
uint32_t threshold_info = MDF_OLD_HIGH_THRESHOLD;
HAL_MDF_PollForOld(&hmdf, timeout, &threshold_info);
hal_mdf_handle_t hmdf;
hal_mdf_old_threshold_info_t threshold_info = MDF_OLD_HIGH_THRESHOLD;
HAL_MDF_OLD_IsDetected(&hmdf, HAL_MDF_BLOCK_INDEX_0, &threshold_info);

HAL MDF Poll for SCD event

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_PollForScd function detects current SCD event for MDF only (not used with ADF):

HAL_MDF_PollForScd(MDF_HandleTypeDef *hmdf, uint32_t Timeout)

In HAL2, if the user wants to wait until SCD event is detected, then he need to call HAL_MDF_SCD_IsDetected function in a loop with a dedicated timeout in the applicative side:

HAL_MDF_SCD_IsDetected(const hal_mdf_handle_t *hmdf,
                       hal_mdf_block_index_t short_circuit_detector_index)

Example usage

MDF_HandleTypeDef hmdf;
uint32_t timeout = 1000;
HAL_MDF_PollForScd(&hmdf, timeout);
hal_mdf_handle_t hmdf;
HAL_MDF_SCD_IsDetected(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF poll for snapshot acquisition

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_PollForSnapshotAcq function waits available snapshot acquisition in polling mode for MDF only (not used with ADF):

HAL_MDF_PollForSnapshotAcq(MDF_HandleTypeDef *hmdf, uint32_t Timeout)

In HAL2, use HAL_MDF_DFLT_PollForSnapshotAcq function to wait available snapshot acquisition in polling mode:

HAL_MDF_DFLT_PollForSnapshotAcq(const hal_mdf_handle_t *hmdf,
                                    hal_mdf_block_index_t digital_filter_index,
                                    uint32_t timeout_ms)

Example usage

MDF_HandleTypeDef hmdf;
uint32_t timeout = 1000;
HAL_MDF_PollForSnapshotAcq(&hmdf,timeout);
hal_mdf_handle_t hmdf;
uint32_t timeout = 1000;
HAL_MDF_DFLT_PollForSnapshotAcq(&hmdf, HAL_MDF_BLOCK_INDEX_0, timeout);

HAL MDF start SCD using polling

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_ScdStart function configures and activates short circuit detector in polling mode for MDF only (not used with ADF):


HAL_MDF_ScdStart(MDF_HandleTypeDef *hmdf,
                 const MDF_ScdConfigTypeDef *pScdConfig)

In HAL2, new API HAL_MDF_SCD_SetConfig is provided to configure the SCD and then start detection using HAL_MDF_SCD_Start API:

HAL_MDF_SCD_SetConfig(hal_mdf_handle_t *hmdf,
                          hal_mdf_block_index_t short_circuit_detector_index,
                          uint32_t threshold,
                          uint32_t break_signals)
HAL_MDF_SCD_Start(hal_mdf_handle_t *hmdf,
                  hal_mdf_block_index_t short_circuit_detector_index)

Example usage

MDF_HandleTypeDef hmdf;
MDF_ScdConfigTypeDef scd_config;
HAL_MDF_ScdStart(&hmdf, &scd_config);
hal_mdf_handle_t hmdf;
uint32_t threshold;
uint32_t break_signals;
HAL_MDF_SCD_SetConfig(&hmdf, HAL_MDF_BLOCK_INDEX_0, threshold, break_signals);
HAL_MDF_SCD_Start(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF start SCD using interrupt

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_ScdStart_IT function configures and activates short circuit detector in interrupt mode for MDF only (not used with ADF):


HAL_MDF_ScdStart_IT(MDF_HandleTypeDef *hmdf,
                    const MDF_ScdConfigTypeDef *pScdConfig)

In HAL2, new API HAL_MDF_SCD_SetConfig is provided to configure the SCD and then start detection using HAL_MDF_SCD_Start_IT API:

HAL_MDF_SCD_SetConfig(hal_mdf_handle_t *hmdf,
                          hal_mdf_block_index_t short_circuit_detector_index,
                          uint32_t threshold,
                          uint32_t break_signals)
HAL_MDF_SCD_Start_IT(hal_mdf_handle_t *hmdf,
                     hal_mdf_block_index_t short_circuit_detector_index)

Example usage

MDF_HandleTypeDef hmdf;
MDF_ScdConfigTypeDef scd_config;
HAL_MDF_ScdStart_IT(&hmdf, &scd_config);
hal_mdf_handle_t hmdf;
uint32_t threshold;
uint32_t break_signals;
HAL_MDF_SCD_SetConfig(&hmdf, HAL_MDF_BLOCK_INDEX_0, threshold, break_signals);
HAL_MDF_SCD_Start_IT(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF stop SCD using polling

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_ScdStop function stops SCD in polling mode for MDF only (not used with ADF):

HAL_MDF_ScdStop(MDF_HandleTypeDef *hmdf)

In HAL2, use HAL_MDF_SCD_Stop function to stop SCD in polling mode:

HAL_MDF_SCD_Stop(hal_mdf_handle_t *hmdf,
                 hal_mdf_block_index_t short_circuit_detector_index)

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_ScdStop(&hmdf);
hal_mdf_handle_t hmdf;
HAL_MDF_SCD_Stop(&hmdf, HAL_MDF_BLOCK_INDEX_0);

HAL MDF stop SCD using interrupt

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_ScdStop_IT function stops SCD in interruption mode for MDF only (not used with ADF):

HAL_MDF_ScdStop_IT(MDF_HandleTypeDef *hmdf)

In HAL2, use HAL_MDF_SCD_Stop_IT function to stop SCD in interruption mode:

HAL_MDF_SCD_Stop_IT(hal_mdf_handle_t *hmdf,
                    hal_mdf_block_index_t short_circuit_detector_index)

Example usage

MDF_HandleTypeDef hmdf;
HAL_MDF_ScdStop_IT(&hmdf);
hal_mdf_handle_t hmdf;
HAL_MDF_SCD_Stop_IT(&hmdf, HAL_MDF_BLOCK_INDEX_0);

Functions applicable for ADF only

HAL MDF Poll for SAD event

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_PollForSad function detects current SAD event for ADF only (not used with MDF):

HAL_MDF_PollForSad(MDF_HandleTypeDef *hmdf, uint32_t Timeout)

In HAL2, if the user wants to wait until SAD event is detected, then he need to call HAL_ADF_SAD_IsDetected function in a loop with a dedicated timeout in the applicative side:

HAL_ADF_SAD_IsDetected(const hal_adf_handle_t *hadf,
                       hal_adf_block_index_t sound_activity_detector_index)

Example usage

MDF_HandleTypeDef hadf;
uint32_t timeout = 1000;
HAL_MDF_PollForSad(&hadf, timeout);
hal_adf_handle_t hadf;
HAL_ADF_SAD_IsDetected(&hadf, HAL_ADF_BLOCK_INDEX_0);

HAL MDF poll for sound level detection

HAL1

HAL2

Function prototype

In HAL1, HAL_MDF_PollForSndLvl function waits available sound level in polling mode for ADF only (not used with MDF):

HAL_MDF_PollForSndLvl(MDF_HandleTypeDef *hmdf, uint32_t Timeout,
                      uint32_t *pSoundLevel, uint32_t *pAmbientNoise)

In HAL2, use HAL_ADF_SAD_PollForSoundLevel function to wait sound level acquisition in polling mode:

HAL_ADF_SAD_PollForSoundLevel(const hal_adf_handle_t *hadf,
                              hal_adf_block_index_t sound_activity_detector_index,
                              uint32_t timeout_ms)

Example usage

MDF_HandleTypeDef hmdf;
uint32_t timeout = 1000;
HAL_MDF_PollForSndLvl(&hmdf,timeout);
hal_adf_handle_t hadf;
uint32_t timeout = 1000;
HAL_ADF_SAD_PollForSoundLevel(&hadf, HAL_ADF_BLOCK_INDEX_0, timeout)